package com.ruoyi.web.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.web.domain.HvHome;
import com.ruoyi.web.mapper.HvHomeMapper;
import com.ruoyi.web.service.IHvHomeService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;

/**
 * 首页Service业务层处理
 *
 * @author ruoyi
 * @date 2023-11-09
 */
@Service
public class HvHomeServiceImpl extends ServiceImpl<HvHomeMapper, HvHome> implements IHvHomeService {

    @Autowired
    private HvHomeMapper hvHomeMapper;

    /**
     * 查询首页列表
     *
     * @param hvHome 首页
     * @return 首页
     */
    @Override
    public List<HvHome> selectHvHomeList(HvHome hvHome)
    {
        List<HvHome> hvHomeList = hvHomeMapper.selectList(buildQueryWrapper(hvHome));
        return hvHomeList;
    }


    private LambdaQueryWrapper<HvHome> buildQueryWrapper(HvHome query) {
        Map<String, Object> params = query.getParams();
        LambdaQueryWrapper<HvHome> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(query.getImgIds()), HvHome::getImgIds, query.getImgIds());
        lqw.orderByDesc(HvHome::getCreateTime);
        return lqw;
    }

}
